﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HSDc.RingleFlow.Api.Kernel;

namespace HSDc.RingleFlow.Api.Service
{
    public interface IRuntimeService
    {
        /// <summary>
        /// Create Process Instance via IProcessDefinition(with no variable)
        /// </summary>
        /// <param name="definition">IProcessDefinition Object</param>
        /// <returns>IProcessInstance</returns>
        IProcessInstance CreateProcessInstance(IProcessDefinition definition);
        /// <summary>
        /// Create Process Instance via Process Definition ID(with no variable)
        /// </summary>
        /// <param name="definitionId">Process Definition ID</param>
        /// <returns>IProcessInstance</returns>
        IProcessInstance CreateProcessInstance(string definitionId);
        /// <summary>
        /// Create Process Instance via IProcessDefinition(with variable)
        /// </summary>
        /// <typeparam name="E">Any type of class</typeparam>
        /// <param name="definition">IProcessDefinition Object</param>
        /// <param name="variables">Process過程中所需的變數</param>
        /// <returns>IProcessInstance</returns>
        IProcessInstance CreateProcessInstance(IProcessDefinition definition, Dictionary<string, object> variables);
        /// <summary>
        /// Create Process Instance via Process Definition ID(with variable)
        /// </summary>
        /// <param name="definitionId">Process Definition ID</param>
        /// <param name="variables">Process過程中所需的變數</param>
        /// <returns>IProcessInstance</returns>
        IProcessInstance CreateProcessInstance(string definitionId, Dictionary<string, object> variables);
        /// <summary>
        /// 取得所有Process Instance的變數
        /// </summary>
        /// <typeparam name="E">Any type of class</typeparam>
        /// <param name="instanceId">Process Instance ID</param>
        /// <returns>所有Process Instance的變數</returns>
        Dictionary<string, object> GetVariables(string instanceId);
        /// <summary>
        /// 取得某一個Process Instance的變數
        /// </summary>
        /// <param name="instanceId">Process Instance ID</param>
        /// <param name="variableName">變數名稱</param>
        /// <returns>變數</returns>
        object GetVaraible(string instanceId, string variableName);
        /// <summary>
        /// 利用Process Instance ID取得Process Instance
        /// </summary>
        /// <param name="instanceId">Process Instance ID</param>
        /// <returns>ProcessInstance</returns>
        IProcessInstance GetProcessInstance(string instanceId);
        /// <summary>
        /// 強制結束一個Process Instance
        /// </summary>
        /// <param name="instance">IProcessInstance Object</param>
        void CompleteProcessInstance(IProcessInstance instance);
        /// <summary>
        /// 查詢某個Instance是否已經完成
        /// </summary>
        /// <param name="instanceId">Process Instance ID</param>
        /// <returns></returns>
        bool IsComplete(string instanceId);
    }
}
